import { request } from '../../plugin/request'

// 获取收货地址
export function getAddressData (uid) {
  return request({
    url: '/user/address/index',
    method: 'get',
    params: {
      uid
    }
  })
}

// 获取收货地址信息
export function addressInfoData (param) {
  return request({
    url: '/user/address/info',
    method: 'get',
    params: {
      uid: param.uid,
      aid: param.aid
    }
  })
}

// 删除收获地址
export function delAddress (param) {
  return request({
    url: '/user/address/del',
    method: 'get',
    params: {
      uid: param.uid,
      aid: param.aid
    }
  })
}

// 修改收货地址
export function editAddress (param) {
  return request({
    url: '/user/address/mod',
    method: 'post',
    data: {
      aid: param.aid,
      uid: param.uid,
      name: param.name,
      cellphone: param.cellphone,
      province: param.province,
      city: param.city,
      area: param.area,
      address: param.address,
      isdefault: param.isdefault
    }
  })
}

// 获取默认收货地址
export function defaultAddress (uid) {
  return request({
    url: '/user/address/defaultAddress',
    method: 'get',
    params: {
      uid
    }
  })
}

// 添加收货地址
export function addAddress (param) {
  return request({
    url: '/user/address/add',
    method: 'post',
    data: {
      uid: param.uid,
      name: param.name,
      cellphone: param.cellphone,
      province: param.province,
      city: param.city,
      area: param.area,
      address: param.address,
      isdefault: param.isdefault
    }
  })
}
